/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * EventS.java
 *
 * Created on Jun 7, 2009, 11:56:21 AM
 */

package DigimonAdventure.UserInterface;

import DigimonAdventure.Database.DigimonSpecies;
import DigimonAdventure.DigimonAdventure;
import javax.swing.ImageIcon;
import DigimonAdventure.MP3Player.MusicPlayer;

/**
 *
 * @author Benz Louis
 */
public class EventS extends javax.swing.JFrame {
    private int event;
    private int click;
    private MusicPlayer bgm;
    private MusicPlayer ending;

    /** Creates new form EventS */
    public EventS() {
        initComponents();
        bgm = new MusicPlayer("/DigimonAdventure/Sound/Stage 3.mp3");
        ending = new MusicPlayer("/DigimonAdventure/Sound/Ending 2.mp3");
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        OuterPanelE = new javax.swing.JLayeredPane();
        CmdNext = new javax.swing.JButton();
        BG = new javax.swing.JLabel();
        TalkerL = new javax.swing.JLabel();
        TalkerR = new javax.swing.JLabel();
        Dialogs = new javax.swing.JLabel();
        CharaR = new javax.swing.JLabel();
        CharaR1 = new javax.swing.JLabel();
        CharaR2 = new javax.swing.JLabel();
        CharaL = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Digimon World Adventure - The Past");
        setAlwaysOnTop(true);
        setMinimumSize(new java.awt.Dimension(1024, 768));
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentHidden(java.awt.event.ComponentEvent evt) {
                formComponentHidden(evt);
            }
            public void componentShown(java.awt.event.ComponentEvent evt) {
                formComponentShown(evt);
            }
        });

        OuterPanelE.setBackground(new java.awt.Color(0, 0, 0));

        CmdNext.setFont(new java.awt.Font("Tahoma", 1, 14));
        CmdNext.setText("Next");
        CmdNext.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CmdNextMouseClicked(evt);
            }
        });
        CmdNext.setBounds(850, 680, 150, 30);
        OuterPanelE.add(CmdNext, javax.swing.JLayeredPane.PALETTE_LAYER);

        BG.setBackground(new java.awt.Color(0, 0, 0));
        BG.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        BG.setIcon(new javax.swing.ImageIcon(getClass().getResource("/DigimonAdventure/Graphics/event.jpg"))); // NOI18N
        BG.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        BG.setBounds(0, 0, 1024, 768);
        OuterPanelE.add(BG, javax.swing.JLayeredPane.DEFAULT_LAYER);

        TalkerL.setFont(new java.awt.Font("Times New Roman", 0, 36));
        TalkerL.setForeground(new java.awt.Color(200, 100, 255));
        TalkerL.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        TalkerL.setText("???");
        TalkerL.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        TalkerL.setOpaque(true);
        TalkerL.setBounds(30, 550, 300, 50);
        OuterPanelE.add(TalkerL, javax.swing.JLayeredPane.PALETTE_LAYER);

        TalkerR.setFont(new java.awt.Font("Times New Roman", 0, 36));
        TalkerR.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        TalkerR.setText("<Digimons>");
        TalkerR.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        TalkerR.setOpaque(true);
        TalkerR.setBounds(700, 550, 300, 50);
        OuterPanelE.add(TalkerR, javax.swing.JLayeredPane.PALETTE_LAYER);

        Dialogs.setBackground(new java.awt.Color(255, 255, 255));
        Dialogs.setFont(new java.awt.Font("Calibri", 0, 20));
        Dialogs.setText("Isi dialognya");
        Dialogs.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        Dialogs.setOpaque(true);
        Dialogs.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                DialogsComponentShown(evt);
            }
        });
        Dialogs.setBounds(14, 570, 1000, 150);
        OuterPanelE.add(Dialogs, javax.swing.JLayeredPane.PALETTE_LAYER);

        CharaR.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        CharaR.setIcon(new javax.swing.ImageIcon(getClass().getResource("/DigimonAdventure/Graphics/Azramon.gif"))); // NOI18N
        CharaR.setBounds(770, 270, 250, 300);
        OuterPanelE.add(CharaR, javax.swing.JLayeredPane.PALETTE_LAYER);

        CharaR1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        CharaR1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/DigimonAdventure/Graphics/greymon.gif"))); // NOI18N
        CharaR1.setBounds(600, 270, 250, 300);
        OuterPanelE.add(CharaR1, javax.swing.JLayeredPane.PALETTE_LAYER);

        CharaR2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        CharaR2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/DigimonAdventure/Graphics/gradmon.gif"))); // NOI18N
        CharaR2.setBounds(450, 270, 250, 300);
        OuterPanelE.add(CharaR2, javax.swing.JLayeredPane.PALETTE_LAYER);

        CharaL.setIcon(new javax.swing.ImageIcon(getClass().getResource("/DigimonAdventure/Graphics/Frags.gif"))); // NOI18N
        CharaL.setBounds(0, 270, 250, 300);
        OuterPanelE.add(CharaL, javax.swing.JLayeredPane.PALETTE_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(OuterPanelE, javax.swing.GroupLayout.DEFAULT_SIZE, 1024, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(OuterPanelE, javax.swing.GroupLayout.DEFAULT_SIZE, 768, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void CmdNextMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CmdNextMouseClicked
        click ++;
        DialogsComponentShown(evt);
}//GEN-LAST:event_CmdNextMouseClicked

    private void DialogsComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_DialogsComponentShown
        switch(event){
            //Opening, Mir dateng ke dunia dgital, ngobrol2 sama "System". To City
            case 1: switch(click){
                case 0: Dialogs.setText("Myrrh's Linker Mode has been Unlocked!!");
                break;
                case 1: Dialogs.setText("This mode utilizes kindness and benevolence as it's fighting prowess");
                break;
                case 2: Dialogs.setText("Among all of Myrrh's form, this one has the highest defensive power and vitality");
                break;
                case 3: this.setVisible(false);
                    DigimonAdventure.pemain.redBit(DigimonAdventure.pemain.getBit());
                    DigimonAdventure.pemain.remItemAt(0);
                    DigimonAdventure.pemain.addDigimon(DigimonSpecies.Linker_I);
                    DigimonAdventure.kotaui.setVisible(true);
                break;
            }break;
            //Dibuka abis ngalahin Boss pertama. Unlock Purger. To city
            case 2: switch(click){
                case 0: Dialogs.setText("Acquired 5000 bits for defeating Azramon!");
                    DigimonAdventure.pemain.addBit(5000);
                break;
                case 1: Dialogs.setText("Myrrh's Purger Mode has been Unlocked!!");
                break;
                case 2: Dialogs.setText("This mode utilizes bravery and vigilance as it's fighting prowess");
                break;
                case 3: Dialogs.setText("Among all of Myrrh's form, this one has the highest attack power");
                break;
                case 4: this.setVisible(false);
                    DigimonAdventure.pemain.addDigimon(DigimonSpecies.Purger_I);
                    DigimonAdventure.kotaui.setVisible(true);
                break;
            }break;
            //Dibuka abis ngalahin boss kedua. Unlock Overseer, munculin masalah. To world map
            case 3: switch(click){
                case 0: Dialogs.setText("Acquired 15000 bits for defeating Charademon!");
                        DigimonAdventure.pemain.addBit(15000);
                break;
                case 1: Dialogs.setText("Myrrh's Overseer Mode has been Unlocked!!");
                break;
                case 2: Dialogs.setText("This mode utilizes wisdom and virtue as it's fighting prowess");
                break;
                case 3: Dialogs.setText("Among all of Myrrh's form, this one has the highest agility factor");
                break;
                case 4: this.setVisible(false);
                    DigimonAdventure.pemain.addDigimon(DigimonSpecies.Overseer_I);
                    DigimonAdventure.petadunia.setVisible(true);
                break;
            }break;
            //Dibuka waktu masuk ke city dari world map, masukin cerita digimon mulai takut sama Mir. To city
            case 4: switch (click){
                case 0: Dialogs.setText("Event4");
                break;
                case 1: this.setVisible(false);
                    DigimonAdventure.kotaui.setVisible(true);
                break;
            }break;
            //Dibuka waktu mau masuk final stage, Mir pertama contact langsung sama Mother Virus. To World Map, HP = 1
            case 5: switch(click){
                case 0: Dialogs.setText("Event4");
                break;
                case 1: this.setVisible(false);
                    DigimonAdventure.pemain.getListDigimon()[0].decLive(DigimonAdventure.pemain.getListDigimon()[0].getLife()-1);
                    DigimonAdventure.pemain.getListDigimon()[1].decLive(DigimonAdventure.pemain.getListDigimon()[1].getLife()-1);
                    DigimonAdventure.pemain.getListDigimon()[2].decLive(DigimonAdventure.pemain.getListDigimon()[2].getLife()-1);
                    DigimonAdventure.petadunia.setVisible(true);
                break;
            }break;
            //Sad ending. Mir ngirim telur Monochromatic Digimon ke DigiWorld, sementara dia mulai kena possess
            case 6: switch(click){
                case 0: Dialogs.setText("The End");
                break;
                case 1: this.setVisible(false);
                    DigimonAdventure.pemain.remAllDigimon();
                    DigimonAdventure.menuutama.setVisible(true);
                break;
            }break;
        }
}//GEN-LAST:event_DialogsComponentShown

    private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
        click = 0;
        event ++;
        new Thread(bgm,"blooming-flowers").start();
        if(event == 1){
            CharaL.setVisible(false);
            CharaR.setVisible(false);
            TalkerR.setVisible(false);
        }
        CharaR1.setVisible(false);
        CharaR2.setVisible(false);
        DialogsComponentShown(evt);
    }//GEN-LAST:event_formComponentShown

    private void formComponentHidden(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentHidden
        bgm.stopMusic();
    }//GEN-LAST:event_formComponentHidden

public int getEvent(){return event;}

protected ImageIcon createImageIcon(String path, String description) {
	java.net.URL imgURL = getClass().getResource(path);
	if (imgURL != null) {
		return new ImageIcon(imgURL, description);
	} else {
		System.err.println("Couldn't find file: " + path);
		return null;
	}
}

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new EventS().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel BG;
    private javax.swing.JLabel CharaL;
    private javax.swing.JLabel CharaR;
    private javax.swing.JLabel CharaR1;
    private javax.swing.JLabel CharaR2;
    private javax.swing.JButton CmdNext;
    private javax.swing.JLabel Dialogs;
    private javax.swing.JLayeredPane OuterPanelE;
    private javax.swing.JLabel TalkerL;
    private javax.swing.JLabel TalkerR;
    // End of variables declaration//GEN-END:variables

}
